package com.api.shopapi.mapper;

import com.api.shopapi.entity.Dishes;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesMapper {

    @Insert("insert into dishes" +
            "(" +
            "DishesCode," +
            "Name," +
            "Status," +
            "CarePlaceCode" +
            ") " +
            "values" +
            "(" +
            "#{dishes.DishesCode}," +
            "#{dishes.Name}," +
            "#{dishes.Status}," +
            "#{dishes.CarePlaceCode}" +
            ")")
    int insert(@Param("dishes") Dishes dishes);

    @Update("update dishes" +
            " set" +
            " Name=#{dishes.Name}," +
            " Status=#{dishes.Status}" +
            " where " +
            " dishesCode=#{dishes.dishesCode}")
    int update(@Param("dishes") Dishes dishes);

    @Select("select * from dishes where dishesCode=#{dishesCode} limit 1")
    Dishes getByDishesCode(@Param("dishesCode") String dishesCode);

    @Select("<script>" +
            "select * from dishes where carePlaceCode=#{carePlaceCode}" +
            "</script>")
    List<Dishes> ListByCarePlaceCode(@Param("carePlaceCode") String carePlaceCode);


}
